<?php
/**
 *控制器类 
 */
namespace components\frame;
class controller extends \api\frame\core implements \api\frame\controller{
    public $call;//回调方法
    public function __construct($config) {
        $this->call = $this->getRouteCall();
        $this->config = \core\config::getFrame($config, $this->call);//调用配置类进行配置处理   
        $path = array('default' => APP_PATH. '/'.$this->call['app'].'/templates/'. $this->config['template']['default'],
            'compile' => APP_PATH. '/'.$this->call['app'].'/templates/system');
        $this->setTplObject($path);
    }
    public function getRouteCall(){
        $class = explode("\\",  get_called_class());
        $call['app'] = isset($class[1])?$class[1]:null;
        $call['module'] = isset($class[3])?$class[3]:null;
        return $call;
    }
    protected function getTplFile($template){
        if($template == null){
            $template = $this->call['module'].'/index'; 
        }elseif(substr_count($template, "/") >= 1){
            $template = $template;            
        }else{
            $template = $this->call['module'].'/'.$template;
        }
        return $template;
    } 
    final public function loadLayout($layout = null){
        if($layout == null){
            $this->loadView("layout/index");
        }else{
            $this->loadView("layout/".$layout);
        }
    }
}

?>
